<%-- 
    Document   : list_products
    Created on : Jan 7, 2013, 10:29:46 PM
    Author     : SONY
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<table border="0" width="650px" cellpadding="10px">        
    <% int col = 0; %>          
    <c:forEach var="product" items="${sessionScope.lstproducts}">
    <% if(col == 0) { %>
        <tr>
    <% } %>

        <td align="center">
        <form method="post" action="<c:url value="/nonmember/addtocart.do" />">
            <a href="<c:url value="/nonmember/product_details.jsp?${product.getProductID()}" />"><img src="<c:url value="/images/products/${product.getImageName()}" />" width='150' height='140' title="${product.getProductName()}"/></a>
            <input type="hidden" name="ImageName" value="${product.getImageName()}"/><br/>
            <span style="color:#BE410B;">${product.getProductName()}</span>
            <input type="hidden" name="ProductName" value="${product.getProductName()}"/><br/>
            <span style="color:#999999;">${product.getProductID()}</span>
            <input type="hidden" name="ProductID" value="${product.getProductID()}"/><br/>
            <span style="color:#b23b08;font-weight:bold;"><fmt:formatNumber type="currency" currencySymbol="" maxFractionDigits="0" value="${product.getUnitPrice()}"/> đ</span>
            <input type="hidden" name="UnitPrice" value="${product.getUnitPrice()}"/><br/>
            <span style="font-weight:bold;color:#e95b5b;">${product.getQoh() le 0 ? "Hết Hàng" : "Còn Hàng"}</span><br/>
            Số Lượng &nbsp;<input type="text" name="quantity"  size=20 class="txtMask"
                                  value="1" style="text-align: right;width: 50px;margin-bottom: 5px;"/><br/>
            <input type="submit" class="btnMask" value="Chọn Mua"/><br/>
        </form>
        </td>
    <% col++; %>

    <% if(col == 3) { %>
        </tr>
    <% col = 0; } %>
    </c:forEach>        
</table>
				<ul id="pagination-flickr">
				<c:forEach var="i" begin="0" end="${sessionScope.nPages - 1}" >
                                    <li><a href="<c:url value="/nonmember/list_products.do" />?action=paging&&currentpage=${i}"> ${i+1}</a></li>
				</c:forEach >
				</ul>  
<%
if(((HttpServletRequest) request).getAttribute("errorMsg") != null) {
        String errorMsg = ((HttpServletRequest) request).getAttribute("errorMsg").toString();
        if(errorMsg.length() > 0) { 
            out.println("<script type=\"text/javascript\">");
            out.println("alert(\"" + errorMsg + "\")");
            out.println("</script>");
        } 
    }
%>        
